@primary: #409eff;
@success: #67c23a;
@warning: #e6a23c;
@danger: #f56c6c;
@info: #909399;
@text-color: #303133;
@text-secondary: #606266;
@border-color: #e4e7ed;
@overlay-bg: rgba(0, 0, 0, 0.45);
@surface: #ffffff;
@radius-lg: 12px;
@shadow-lg: 0 18px 48px rgba(20, 20, 20, 0.32);

:root {
  --ng-confirm-primary: @primary;
  --ng-confirm-success: @success;
  --ng-confirm-warning: @warning;
  --ng-confirm-danger: @danger;
  --ng-confirm-info: @info;
  --ng-confirm-text-color: @text-color;
  --ng-confirm-text-secondary: @text-secondary;
  --ng-confirm-border-color: @border-color;
  --ng-confirm-overlay-bg: @overlay-bg;
  --ng-confirm-surface: @surface;
  --ng-confirm-radius-lg: @radius-lg;
  --ng-confirm-shadow: @shadow-lg;
}

.ng-confirm-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--ng-confirm-overlay-bg);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.24s ease;

  &.ng-hide-add,
  &.ng-hide-remove {
    transition: opacity 0.24s ease;
  }

  &.ng-hide {
    opacity: 0;
    pointer-events: none;
  }

  &:not(.ng-hide) {
    opacity: 1;
  }

  &:not(.ng-hide) .ng-confirm-dialog {
    transform: translateY(0) scale(1);
    opacity: 1;
    animation: dialogIn 0.22s ease forwards;
  }
}

.ng-confirm-dialog {
  background: var(--ng-confirm-surface);
  border-radius: var(--ng-confirm-radius-lg);
  box-shadow: var(--ng-confirm-shadow);
  min-width: 380px;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  color: var(--ng-confirm-text-color);
  transform: translateY(12px) scale(0.96);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.ng-confirm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--ng-confirm-border-color);
}

.ng-confirm-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--ng-confirm-text-color);
}

.ng-confirm-close {
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 30px;
  color: var(--ng-confirm-info);
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;

  &:hover {
    background-color: fade(@primary, 8%);
    color: var(--ng-confirm-primary);
  }
}

.ng-confirm-body {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px 24px;
}

.ng-confirm-icon {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background-color: fade(@primary, 12%);
  color: var(--ng-confirm-primary);

  &-warning {
    background-color: fade(@warning, 12%);
    color: var(--ng-confirm-warning);
  }

  &-info {
    background-color: fade(@info, 12%);
    color: var(--ng-confirm-info);
  }

  &-success {
    background-color: fade(@success, 12%);
    color: var(--ng-confirm-success);
  }

  &-error,
  &-danger {
    background-color: fade(@danger, 12%);
    color: var(--ng-confirm-danger);
  }

  .ng-confirm-icon-content {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .ng-confirm-icon-symbol {
    width: 32px;
    height: 32px;
    display: block;
  }
}

.ng-confirm-content {
  flex: 1;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ng-confirm-text-secondary);
  word-break: break-word;
}

.ng-confirm-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 24px 20px;
  border-top: 1px solid var(--ng-confirm-border-color);
}

.ng-confirm-btn {
  min-width: 96px;
  height: 36px;
  padding: 0 18px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
  outline: none;

  &:focus-visible {
    box-shadow: 0 0 0 2px fade(@primary, 35%);
  }

  &:active {
    transform: scale(0.98);
  }

  &-cancel {
    background-color: #fff;
    color: var(--ng-confirm-text-secondary);
    border-color: var(--ng-confirm-border-color);

    &:hover {
      background-color: fade(@primary, 8%);
      color: var(--ng-confirm-primary);
      border-color: fade(@primary, 45%);
    }
  }

  &-confirm {
    color: #fff;

    &.ng-confirm-btn-info {
      background-color: var(--ng-confirm-info);
      border-color: var(--ng-confirm-info);
      box-shadow: 0 10px 20px fade(@info, 25%);

      &:hover {
        background-color: lighten(@info, 8%);
        border-color: lighten(@info, 8%);
        box-shadow: 0 12px 26px fade(@info, 28%);
      }

      &:active {
        background-color: darken(@info, 8%);
        border-color: darken(@info, 8%);
      }
    }

    &.ng-confirm-btn-success {
      background-color: var(--ng-confirm-success);
      border-color: var(--ng-confirm-success);
      box-shadow: 0 10px 20px fade(@success, 25%);

      &:hover {
        background-color: lighten(@success, 8%);
        border-color: lighten(@success, 8%);
        box-shadow: 0 12px 26px fade(@success, 28%);
      }

      &:active {
        background-color: darken(@success, 8%);
        border-color: darken(@success, 8%);
      }
    }

    &.ng-confirm-btn-warning {
      background-color: var(--ng-confirm-warning);
      border-color: var(--ng-confirm-warning);
      box-shadow: 0 10px 20px fade(@warning, 25%);

      &:hover {
        background-color: lighten(@warning, 8%);
        border-color: lighten(@warning, 8%);
        box-shadow: 0 12px 26px fade(@warning, 28%);
      }

      &:active {
        background-color: darken(@warning, 8%);
        border-color: darken(@warning, 8%);
      }
    }

    &.ng-confirm-btn-danger {
      background-color: var(--ng-confirm-danger);
      border-color: var(--ng-confirm-danger);
      box-shadow: 0 10px 20px fade(@danger, 25%);

      &:hover {
        background-color: lighten(@danger, 8%);
        border-color: lighten(@danger, 8%);
        box-shadow: 0 12px 26px fade(@danger, 28%);
      }

      &:active {
        background-color: darken(@danger, 8%);
        border-color: darken(@danger, 8%);
      }
    }
  }

  &:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
  }
}

@media (max-width: 480px) {
  .ng-confirm-dialog {
    min-width: auto;
    width: calc(100vw - 24px);
  }

  .ng-confirm-body {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .ng-confirm-icon {
    margin-bottom: 8px;
  }

  .ng-confirm-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .ng-confirm-btn {
    width: 100%;
  }
}

@keyframes dialogIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
